UNPKG

ccdash

Version:

Claude Code Dashboard - A comprehensive monitoring dashboard for Claude Code

1 lines 16.9 kB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[824],{1497:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(9946).A)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},1725:(e,s,t)=>{Promise.resolve().then(t.bind(t,2712))},2712:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>B});var a=t(5155),n=t(2115),i=t(5695),r=t(7168),l=t(8482),c=t(8145),d=t(3655),o="horizontal",m=["horizontal","vertical"],x=n.forwardRef((e,s)=>{var t;let{decorative:n,orientation:i=o,...r}=e,l=(t=i,m.includes(t))?i:o;return(0,a.jsx)(d.sG.div,{"data-orientation":l,...n?{role:"none"}:{"aria-orientation":"vertical"===l?l:void 0,role:"separator"},...r,ref:s})});x.displayName="Separator";var h=t(3999);let u=n.forwardRef((e,s)=>{let{className:t,orientation:n="horizontal",decorative:i=!0,...r}=e;return(0,a.jsx)(x,{ref:s,decorative:i,orientation:n,className:(0,h.cn)("shrink-0 bg-border","horizontal"===n?"h-[1px] w-full":"h-full w-[1px]",t),...r})});u.displayName=x.displayName;var p=t(9946);let j=(0,p.A)("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var g=t(3052);let f=(0,p.A)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),N=e=>{let{className:s,...t}=e;return(0,a.jsx)("nav",{role:"navigation","aria-label":"pagination",className:(0,h.cn)("mx-auto flex w-full justify-center",s),...t})};N.displayName="Pagination";let v=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)("ul",{ref:s,className:(0,h.cn)("flex flex-row items-center gap-1",t),...n})});v.displayName="PaginationContent";let y=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)("li",{ref:s,className:(0,h.cn)("",t),...n})});y.displayName="PaginationItem";let w=e=>{let{className:s,isActive:t,size:n="icon",...i}=e;return(0,a.jsx)("a",{"aria-current":t?"page":void 0,className:(0,h.cn)((0,r.r)({variant:t?"outline":"ghost",size:n}),s),...i})};w.displayName="PaginationLink";let k=e=>{let{className:s,...t}=e;return(0,a.jsxs)(w,{"aria-label":"Go to previous page",size:"default",className:(0,h.cn)("gap-1 pl-2.5",s),...t,children:[(0,a.jsx)(j,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"Previous"})]})};k.displayName="PaginationPrevious";let b=e=>{let{className:s,...t}=e;return(0,a.jsxs)(w,{"aria-label":"Go to next page",size:"default",className:(0,h.cn)("gap-1 pr-2.5",s),...t,children:[(0,a.jsx)("span",{children:"Next"}),(0,a.jsx)(g.A,{className:"h-4 w-4"})]})};b.displayName="PaginationNext";let _=e=>{let{className:s,...t}=e;return(0,a.jsxs)("span",{"aria-hidden":!0,className:(0,h.cn)("flex h-9 w-9 items-center justify-center",s),...t,children:[(0,a.jsx)(f,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"sr-only",children:"More pages"})]})};_.displayName="PaginationEllipsis";let S=(0,p.A)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);var A=t(7550),C=t(5196),z=t(4357),M=t(1497);let D=(0,p.A)("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),P=(0,p.A)("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var E=t(4186),L=t(1886),R=t(1380),O=t(2261);function U(){let{t:e,formatFullDate:s}=(0,O.s)(),t=(0,i.useParams)(),d=(0,i.useRouter)(),o=(0,i.useSearchParams)(),m=null==t?void 0:t.id,[x,h]=(0,n.useState)(null),[p,j]=(0,n.useState)(!0),[g,f]=(0,n.useState)(null),[U,T]=(0,n.useState)(1),[B]=(0,n.useState)(20),[H,J]=(0,n.useState)(!1);(0,n.useEffect)(()=>{T(parseInt((null==o?void 0:o.get("page"))||"1"))},[o]),(0,n.useEffect)(()=>{let e=async()=>{try{j(!0),f(null);let e=await L.F.sessions.getById(m,U,B);h(e)}catch(e){f(e instanceof Error?e.message:"Unknown error")}finally{j(!1)}};m&&e()},[m,U,B]);let Z=e=>s(new Date(e)),I=e=>e?(e.match(/```[\s\S]*?```/g)||[]).map(e=>e.replace(/```\w*\n?|\n```/g,"").trim()):[],W=s=>{if(!s.content)return(0,a.jsx)("div",{className:"text-muted-foreground text-sm",children:e("session.noContent")});if("object"==typeof s.content&&null!==s.content)return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:e("session.rawObjectContent")}),(0,a.jsx)("pre",{className:"bg-muted p-3 rounded-md text-xs max-w-full min-w-0",children:JSON.stringify(s.content,null,2)})]});if("string"==typeof s.content&&s.content.trim().startsWith("[")&&s.content.trim().endsWith("]"))try{let t=JSON.parse(s.content);if(Array.isArray(t))return(0,a.jsx)("div",{className:"space-y-2",children:t.map((s,t)=>(0,a.jsxs)("div",{className:"bg-muted p-3 rounded-md",children:["text"===s.type&&(0,a.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm max-w-full overflow-hidden",children:s.text}),"tool_use"===s.type&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,a.jsx)(S,{className:"w-4 h-4"}),(0,a.jsx)("span",{className:"font-medium",children:s.name})]}),(0,a.jsx)("pre",{className:"bg-background p-2 rounded overflow-x-scroll max-w-full min-w-0 text-xs whitespace-pre-wrap",children:JSON.stringify(s.input,null,2)})]}),"tool_result"===s.type&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,a.jsx)(S,{className:"w-4 h-4"}),(0,a.jsx)("span",{className:"font-medium",children:e("session.toolResult")}),s.tool_use_id&&"string"==typeof s.tool_use_id?(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",s.tool_use_id.slice(-8),")"]}):null]}),(0,a.jsx)("div",{className:"text-xs bg-background p-2 rounded whitespace-pre-wrap break-words max-w-full overflow-hidden",children:"string"==typeof s.content?s.content:JSON.stringify(s.content,null,2)})]}),"thinking"===s.type&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,a.jsxs)("span",{className:"font-medium text-purple-600",children:["\uD83D\uDCAD ",e("session.thinking")]})}),(0,a.jsx)("div",{className:"text-xs bg-purple-50 p-2 rounded whitespace-pre-wrap",children:String(s.thinking)})]}),!s.type&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:e("session.unknownItemType")}),(0,a.jsx)("pre",{className:"text-xs bg-background p-2 rounded overflow-x-auto max-w-full min-w-0",children:JSON.stringify(s,null,2)})]})]},t))})}catch(e){}let t="string"==typeof s.content?s.content:JSON.stringify(s.content),n=I(t),i=t.replace(/```[\s\S]*?```/g,"[".concat(e("session.codeBlocks"),"]"));return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm max-w-full overflow-hidden",children:i}),n.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,a.jsx)(S,{className:"w-4 h-4"}),e("session.codeGenerated")," (",n.length,"個)"]}),n.map((e,s)=>(0,a.jsx)("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto max-w-full min-w-0",children:e},s))]})]})};if(p)return(0,a.jsx)("div",{className:"min-h-screen bg-background flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),(0,a.jsx)("p",{children:e("errors.sessionDetailFetch")})]})});if(g)return(0,a.jsx)("div",{className:"min-h-screen bg-background flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsxs)("p",{className:"text-red-600 mb-4",children:[e("common.error"),": ",g]}),(0,a.jsx)(r.$,{onClick:()=>d.push("/"),children:e("common.back")})]})});if(!x)return(0,a.jsx)("div",{className:"min-h-screen bg-background flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"mb-4",children:e("errors.sessionNotFound")}),(0,a.jsx)(r.$,{onClick:()=>d.push("/"),children:e("common.back")})]})});let{session:$,messages:F}=x,G=e=>!!(e&&"object"==typeof e&&null!==e&&"messages"in e&&"total"in e),q=G(F)?F.messages:F,V=G(F)?F.total:F.length,X=G(F)?F:null,Y=e=>{let s=new URL(window.location.href);s.searchParams.set("page",e.toString()),d.push(s.pathname+s.search)};return(0,a.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,a.jsx)(R.Y,{}),(0,a.jsxs)("div",{className:"container mx-auto max-w-7xl p-6 space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)(r.$,{variant:"outline",size:"sm",onClick:()=>d.push("/?tab=sessions"),children:[(0,a.jsx)(A.A,{className:"w-4 h-4 mr-2"}),e("common.back")]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-bold",children:e("session.detail")}),(0,a.jsx)("p",{className:"text-muted-foreground",children:$.project_path.split("/").pop()})]})]}),(0,a.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,a.jsxs)(l.Zp,{children:[(0,a.jsx)(l.aR,{children:(0,a.jsx)(l.ZB,{className:"text-lg",children:e("session.info")})}),(0,a.jsx)(l.Wu,{className:"space-y-4",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.sessionId")}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,a.jsx)("code",{className:"font-mono text-xs bg-muted px-2 py-1 rounded flex-1 truncate",children:$.id}),(0,a.jsx)(r.$,{variant:"outline",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText($.id);else{let e=document.createElement("textarea");e.value=$.id,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}J(!0),setTimeout(()=>J(!1),2e3)}catch(e){}},className:"h-6 w-6 p-0",children:H?(0,a.jsx)(C.A,{className:"w-3 h-3"}):(0,a.jsx)(z.A,{className:"w-3 h-3"})})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.project")}),(0,a.jsx)("p",{className:"font-medium break-all",children:$.project_path})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.status")}),(0,a.jsx)("div",{className:"mt-1",children:(0,a.jsx)(c.E,{variant:$.is_active?"default":"secondary",children:$.is_active?e("session.active"):e("session.completed")})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.startTime")}),(0,a.jsx)("p",{className:"font-medium",children:Z($.start_time)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.duration")}),(0,a.jsx)("p",{className:"font-medium",children:((s,t)=>{let a=new Date(s),n=Math.floor(((t?new Date(t):new Date).getTime()-a.getTime())/6e4),i=Math.floor(n/60);return i>0?"".concat(i," ").concat(e("tokenUsage.hours")," ").concat(n%60," ").concat(e("tokenUsage.minutes")):"".concat(n," ").concat(e("tokenUsage.minutes"))})($.start_time,$.end_time)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.messageCount")}),(0,a.jsx)("p",{className:"font-medium",children:$.message_count})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.lastActivity")}),(0,a.jsx)("p",{className:"font-medium",children:Z($.last_activity)})]})]})})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsx)(l.aR,{children:(0,a.jsx)(l.ZB,{className:"text-lg",children:e("session.tokenUsage")})}),(0,a.jsx)(l.Wu,{className:"space-y-4",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.total")}),(0,a.jsx)("p",{className:"text-2xl font-bold",children:$.total_tokens.toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.cost")}),(0,a.jsxs)("p",{className:"text-2xl font-bold",children:["$",$.total_cost.toFixed(4)]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("session.input")," ",e("tokenUsage.tokens")]}),(0,a.jsx)("p",{className:"font-medium",children:$.total_input_tokens.toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("session.output")," ",e("tokenUsage.tokens")]}),(0,a.jsx)("p",{className:"font-medium",children:$.total_output_tokens.toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e("session.messages")}),(0,a.jsx)("p",{className:"font-medium",children:$.message_count})]})]})})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)(l.aR,{children:[(0,a.jsxs)(l.ZB,{className:"text-lg flex items-center gap-2",children:[(0,a.jsx)(M.A,{className:"w-5 h-5"}),e("session.messageHistory")," (",V,")"]}),(0,a.jsxs)(l.BT,{children:[e("session.messageHistory"),X&&(0,a.jsxs)("span",{className:"ml-2",children:["(",e("session.page")," ",X.page," / ",X.total_pages,")"]})]})]}),(0,a.jsxs)(l.Wu,{children:[(0,a.jsx)("div",{className:"pr-4",children:(0,a.jsx)("div",{className:"space-y-4",children:q.map((s,t)=>(0,a.jsxs)("div",{className:"border rounded-lg p-4 min-w-0 overfl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["user"===s.message_role?(0,a.jsx)(D,{className:"w-4 h-4 text-blue-600"}):(0,a.jsx)(P,{className:"w-4 h-4 text-green-600"}),(0,a.jsx)("span",{className:"font-medium capitalize",children:"user"===s.message_role?e("session.user"):e("session.assistant")}),s.model&&(0,a.jsx)(c.E,{variant:"outline",className:"text-xs",children:s.model})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"w-3 h-3"}),Z(s.timestamp)]})]}),s.content&&(0,a.jsx)("div",{className:"mb-3",children:W(s)}),"assistant"===s.message_role&&(s.input_tokens>0||s.output_tokens>0)&&(0,a.jsxs)("div",{className:"flex items-center gap-4 text-xs text-muted-foreground border-t pt-2",children:[(0,a.jsxs)("span",{children:[e("session.input"),": ",s.input_tokens.toLocaleString()]}),(0,a.jsxs)("span",{children:[e("session.output"),": ",s.output_tokens.toLocaleString()]}),(0,a.jsxs)("span",{children:[e("session.total"),": ",(s.input_tokens+s.output_tokens).toLocaleString()]}),s.service_tier&&(0,a.jsx)(c.E,{variant:"outline",className:"text-xs",children:s.service_tier})]}),t<q.length-1&&(0,a.jsx)(u,{className:"mt-4"})]},s.id))})}),X&&X.total_pages>1&&(0,a.jsx)("div",{className:"mt-6",children:(0,a.jsx)(N,{children:(0,a.jsxs)(v,{children:[(0,a.jsx)(y,{children:(0,a.jsx)(k,{href:"#",onClick:e=>{e.preventDefault(),X.has_previous&&Y(X.page-1)},className:X.has_previous?"":"pointer-events-none opacity-50"})}),(()=>{let e=[],s=X.page,t=X.total_pages;s>3&&(e.push((0,a.jsx)(y,{children:(0,a.jsx)(w,{href:"#",onClick:e=>{e.preventDefault(),Y(1)},children:"1"})},1)),s>4&&e.push((0,a.jsx)(y,{children:(0,a.jsx)(_,{})},"ellipsis1")));let n=Math.max(1,s-2),i=Math.min(t,s+2);for(let t=n;t<=i;t++)e.push((0,a.jsx)(y,{children:(0,a.jsx)(w,{href:"#",isActive:t===s,onClick:e=>{e.preventDefault(),Y(t)},children:t})},t));return s<t-2&&(s<t-3&&e.push((0,a.jsx)(y,{children:(0,a.jsx)(_,{})},"ellipsis2")),e.push((0,a.jsx)(y,{children:(0,a.jsx)(w,{href:"#",onClick:e=>{e.preventDefault(),Y(t)},children:t})},t))),e})(),(0,a.jsx)(y,{children:(0,a.jsx)(b,{href:"#",onClick:e=>{e.preventDefault(),X.has_next&&Y(X.page+1)},className:X.has_next?"":"pointer-events-none opacity-50"})})]})})})]})]})]})]})}function T(){return(0,a.jsx)("div",{className:"min-h-screen bg-background flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),(0,a.jsx)("p",{children:"Loading session details..."})]})})}function B(){return(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(T,{}),children:(0,a.jsx)(U,{})})}},4357:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(9946).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},7550:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(9946).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])}},e=>{var s=s=>e(e.s=s);e.O(0,[205,433,972,999,441,684,358],()=>s(1725)),_N_E=e.O()}]);